<html><head>

<!-- ---------------------------------------------------------------------
Simple3D Sample 1
Copyright (c) 2011 Eduardo Poyart. See Simple3D.js for license.
---------------------------------------------------------------------- -->

<script type="text/javascript" src="../util/webgl-utils.js"></script>
<script type="text/javascript" src="../util/J3DI.js"> </script>
<script type="text/javascript" src="../util/gl-matrix.js"> </script>
<script type="text/javascript" src="../Simple3D.js"> </script>

<script type="text/javascript">

var S3D, box, sphere;
var t;

function update(dt)
{
	t += dt;
	mat4.identity(box.matrix);
	mat4.translate(box.matrix, [-Math.sin(t*1.2) - 2.4, 0.0, 0.0]);
	mat4.rotateY(box.matrix, t);
	mat4.identity(sphere.matrix);
	mat4.translate(sphere.matrix, [Math.sin(t*1.2) + 2.4, 0.0, 0.0]);
	mat4.rotateY(sphere.matrix, t);
}

function main()
{
	t = 0;
	S3D = new Simple3D('canvas');
	S3D.setClearColor([0.0, 0.2, 0.4, 1.0]);
	box = S3D.addBox();
	box.colorAmbient = [ 0.0, 0.1, 0.1, 1.0 ];
	box.colorDiffuse = [ 0.0, 0.9, 0.9, 1.0 ];
	sphere = S3D.addSphere(8);
	sphere.colorAmbient = [ 0.1, 0.1, 0.0, 1.0 ];
	sphere.colorDiffuse = [ 0.9, 0.9, 0.0, 1.0 ];
	var light = S3D.addLight();
	light.setPosition([-3, 10, 10]);
	var camera = S3D.addCamera();
	mat4.translate(camera.matrix, [0, 2, 8]);
	mat4.rotateX(camera.matrix, -0.2);
	S3D.run(update);
}

</script>

</head><body onload="main()">

<canvas id="canvas" width="720" height="480">
    If you're seeing this your web browser doesn't support the &lt;canvas&gt; element. Ouch!
</canvas>

</body></html>

